<template>
  <div class="app-container"></div>
</template>

<script>
import { getRdsCluster } from '@/api/rds/cluster'
import { snakeCaseObject } from '@/libs/object'

export default {
  name: 'ClusterDetail',
  components: {},
  data() {
    return {
      instanceColumns: [],
      databaseColumns: [],
      instanceDatas: [],
      databaseDatas: [],
      expandedDatabaseName: ''
    }
  },
  computed: {
    clusterId() {
      return this.$route.params.clusterId
    }
  },
  mounted() {},
  methods: {
    async getRdsCluster() {
      const { data } = await getRdsCluster(snakeCaseObject(this.clusterId))
      this.instanceDatas = data.instances
      this.databaseDatas = data.databases
    },
    onExpand(row, status) {
      this.databasesDatas.splice()
      if (status) {
        this.databasesDatas.filter((item, index) => {
          item._expanded = item.name === row.name
          this.expandedDatabaseName = row.name
          return item
        })
      } else {
        this.databasesDatas.map((item, index) => {
          item._expanded = false
          return item
        })
      }
    }
  }
}
</script>

<style lang='scs' scoped>
</style>
